#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main()
{
	int a = 0, b = 0, m = 0, n = 0, tem = 0, arr1[1000] = { 0 }, arr2[1000] = { 0 };
	scanf("%d %d", &n, &m);
	for (a = 0;a < n;a++)
	{
		scanf("%d", &arr1[a]);
	}
	for (b = 0;b < m;b++)
	{
			scanf("%d", &arr2[b]);
	}
	int arr[2000] = { 0 };
	for (a = 0;a < m + n;a++)
	{
		if (a < n)
			arr[a] = arr1[a];
		else
			arr[a] = arr2[a - n];
	}
	for (a = 0;a < m + n - 1;a++)
	{
		for (b = 0;b < m + n - 1 - a;b++)
		{
			if (arr[b] > arr[b + 1])
			{
				tem = arr[b];
				arr[b] = arr[b + 1];
				arr[b + 1] = tem;
			}
		}
	}
	for (a = 0;a < m + n;a++)
		printf("%d ", arr[a]);
	return 0;
}